package _220316;


/**
 * @author ShadowLim
 * @create 2022-03-16-10:43
 */
public class _含2天数 {

    public static void main(String[] args) {
        int stYear = 1900, edYear = 9999;
        int oneYear = 0;
        int ans= 0;
        // 每个月中日期含2的有【2 12 20~29 共12个】 除去2与12月 共有 10* 12 = 120天含2
        // 月份中含2的有2月 12月 12月有31 天  120+31= 151 = orderDay
        int orderDay = 151;

        for (int i = stYear; i <= edYear; i++) {
            if (isIncludeTwo(i)) {
                if (isLeap(i)) {
                    oneYear = 366;
                } else {
                    oneYear = 365;
                }
            } else {
                if (isLeap(i)) {
                    oneYear = orderDay + 29;
                } else {
                    oneYear = orderDay + 28;
                }
            }
            ans = ans + oneYear;
        }
        System.out.println(ans);
    }


    // 含2的年份
    private static boolean isIncludeTwo(int y) {
        while (y != 0) {
            if (y % 10 == 2) {
                return true;
            }
            y /= 10;
        }
        return false;
    }
    // 闰年判断
    private static boolean isLeap(int y) {
        if ((y % 100 == 0) && (y % 400 == 0)) {
            return true;
        }
        if ((y % 100 != 0) && (y % 4 == 0)) {
            return true;
        }
        return false;
    }
}



